<template>
    <div id="app">
        <el-container>
         

            <el-header class="app" v-show="show">
                 <h1>后台管理</h1>
                <div>
                    <el-menu
                        class="el-menu-demo"
                        mode="horizontal"
                        background-color="#545c64"
                        text-color="#fff"
                        active-text-color="#ffd04b"
                        router
                    >
                        <el-menu-item index="/user">学生管理</el-menu-item>
                        <el-menu-item index="/lao">老师管理</el-menu-item>
                        <el-menu-item index="4">设置</el-menu-item>
                           <el-menu-item @click="tui">退出登录</el-menu-item>
                        <el-menu-item >用户{{$store.state.user.user}}</el-menu-item>
                        
                    </el-menu>
                    
                </div>
            </el-header>
        </el-container>
        <router-view />
    </div>
</template>
<script>
export default {
  methods:{
    tui(){
      this.$store.commit("tui")
       this.$router.push("/login")
    }
  },
   watch: {
    $route: {
      handler(newval, oldval) {
        console.log(newval, oldval);
        if (newval.path == "/login") {
          this.show = false;
        } else {
          this.show = true;
        }
      },
    },
  },
}
</script>
<style lang="scss">
#app {
    font-family: Avenir, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-align: center;
    color: #2c3e50;
}

#nav {
    padding: 30px;

    a {
        font-weight: bold;
        color: #2c3e50;

        &.router-link-exact-active {
            color: #42b983;
        }
    }
}
.app{
  display:flex;
  background:#545C64;
  justify-content: space-between;
}

</style>
